// pages/press/list/list.js
const api = require("../../../comm/api")
const http = require("../../../utils/http")
const util = require("../../../utils/util")
import Notify from '../../../components/@vant/weapp/notify/notify';

Page({

    /**
     * 页面的初始数据
     */
    data: {
        keyword: '',
        newses: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        const keyword = options.keyword
        this.setData({
            keyword: keyword
        })
        this.searchNews({
            detail: keyword
        })
    },

    searchNews(e) {
        const keyword = e.detail
        this.setData({
            keyword: keyword
        })
        http.getJSON(api.Press.List.PATH + "?title=" + keyword, pojo => {
            const newses = pojo.data
            this.setData({
                newses: newses
            })
        }, err => {
            Notify({
                type: 'warning',
                message: JSON.stringify(err)
            })
        })
    },

    exitSearch() {
        wx.navigateBack()
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

})